#ifndef TM_
#define TM_

#include <SDL.h>
#include <SDL_image.h>
#include <string>
#include <map>

class TextureManager {
public:
    bool Load(std::string file_name, std::string textureid, SDL_Renderer* renderer);
    void Draw(std::string textureid, int x, int y, int width, int height, SDL_Renderer* renderer, SDL_RendererFlip flip = SDL_FLIP_NONE);
    void DrawFrame(std::string textureid, int x, int y, int width, int height, int current_row, int current_frame, SDL_Renderer* renderer, SDL_RendererFlip flip = SDL_FLIP_NONE);
    void ClearFromTextureMap(std::string textureid);

    // 懒汉式(需要的时候再生成一个对象指针，实际上返回对象引用更好)
    static TextureManager& instance() {
        static TextureManager singleton;
        return singleton;
    }

private:
    TextureManager();
    ~TextureManager();
    std::map<std::string, SDL_Texture*> texture_map_;

};

typedef TextureManager TheTM;

#endif // __TM__
